package com.example.demo.service;
import com.example.demo.dao.TypeDao;
import com.example.demo.entity.Params;
import com.example.demo.entity.Type;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class TypeService {

    @Resource
    private TypeDao typeDao;

    public  PageInfo<Type> findBySearch(Params params) {
        //开启分页查询
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        List<Type> bySearch = typeDao.findBySearch(params);
        return PageInfo.of(bySearch);
    }
    public void add(Type type) {
        typeDao.insertSelective(type);
    }
    public void update(Type type) {
        typeDao.updateByPrimaryKeySelective(type);
    }

    public void delete(Integer id) {
       typeDao.deleteByPrimaryKey(id);
    }

    public List<Type> findAll() {
        return typeDao.selectAll();
    }
}
